package com.yf.stat.modules.repo.dto.response;

import com.yf.ability.excel.annotation.ExcelField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
* <p>
* 题库总体统计响应类
* </p>
*
* @author 聪明笨狗
* @since 2020-09-11 11:10
*/
@Data
@ApiModel(value="题库总体统计响应类", description="题库总体统计响应类")
public class StatRepoTotalDTO implements Serializable {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "题库ID", required=true)
    private String id;

    @ExcelField(title = "题库名称")
    @ApiModelProperty(value = "题库名称", required=true)
    private String title;

    @ExcelField(title = "训练人数")
    @ApiModelProperty(value = "训练人数")
    private Integer userCount;

    @ExcelField(title = "答题数量")
    @ApiModelProperty(value = "答题数量")
    private Integer answerCount;

    @ExcelField(title = "答对题数")
    @ApiModelProperty(value = "答对题数")
    private Integer rightCount;

    @ExcelField(title = "正确率%", sort = 3)
    private Integer rightRate;

    /**
     * 总体正确率
     * @return
     */
    public Integer getRightRate(){

        // 无人通过
        if(answerCount==null || answerCount.equals(0) || rightCount==null || rightCount==0){
            return 0;
        }

        // 完成用户
        return rightCount*100/answerCount;
    }
}
